import { Controller } from 'egg';

export default class NewsController extends Controller {
  public async index() {
    const { ctx, service } = this;
    const listTemp = await service.news.getData();
    const list = await service.news.joinHref(listTemp);
    await ctx.render('news', {
      list,
    });
  }

  // 新闻详情
  public async content() {
    interface QueryType {
      aid: string;
    }

    const { ctx, service } = this;
    const queryAid: QueryType = ctx.query;
    const list = await service.news.getNewsContent(queryAid.aid);
    await ctx.render('newsContent', {
      list,
    });
  }
}
